
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="./js/vue.js" ></script>

</head>
<body>
    
    <div id="app">
        <!-- 
            循环结构:
            - v-for 遍历数组
                - <li v-for='item in fruits'>{{item}}</li>
                - <li v-for='(item,index) in fruits'> {{item+'---'+index}}</li>
            - key的作用: 帮助vue区分不同的元素,从而提高性能
                - <li :key='item.id' v-for='(item,index) in myFruits'> <span>{{item.ename}}</span></li>
        -->
        <div>水果列表</div>
        <ul>
            <li v-for='item in fruits'>{{item}}</li>
            <li v-for='(item,index) in fruits'> {{item+'---'+index}}</li>
            <li :key='item.id' v-for='(item,index) in myFruits'> 
                <span>{{item.ename}}</span>
                <span>------</span>
                <span>{{item.cname}}</span>
            </li>
        </ul>

    </div>

    <script type="text/javascript">
       var vm = new Vue({
            el:'#app',
            data:{
                fruits:['apple','orange','banana'],
                myFruits:[
                    {id:1,ename:'apple',cname:'苹果'},
                    {id:2,ename:'orange',cname:'桔子'},
                    {id:3,ename:'banana',cname:'香蕉'},
                ]
            },
            methods:{
                handle:function(event){
                    this.flag = !this.flag;
                }
            }
       })      
       
    </script>
</body>
</html>


       